
CMAKE_MINIMUM_REQUIRED(VERSION 2.8)

PROJECT(FileDispatcher)

INCLUDE(${CMAKE_CURRENT_SOURCE_DIR}/../check_bits.cmake)

# Qt5 Begin
FIND_PACKAGE(Qt5Widgets REQUIRED)
FIND_PACKAGE(Qt5Gui REQUIRED)
FIND_PACKAGE(Qt5Sql REQUIRED)

INCLUDE_DIRECTORIES(${Qt5Widgets_INCLUDE_DIRS})
INCLUDE_DIRECTORIES(${Qt5Gui_INCLUDES_DIRS})
INCLUDE_DIRECTORIES(${Qt5Sql_INCLUDES_DIRS})

ADD_DEFINITIONS(${Qt5Widgets_DEFINITIONS})
ADD_DEFINITIONS(${Qt5Gui_DEFINITIONS})
ADD_DEFINITIONS(${Qt5Sql_DEFINITIONS})

SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}
                     ${Qt5Core_EXECUTABLE_COMPILE_FLAGS}
                     ${Qt5Widgets_EXECUTABLE_COMPILE_FLAGS}
                     ${Qt5Gui_EXECUTABLE_COMPILE_FLAGS}
                     ${Qt5Sql_EXECUTABLE_COMPILE_FLAGS}")

SET(QT_USE_QTMAIN TRUE)
# Qt5 End

# Data Begin
FILE(GLOB DATA_HEADERS "Data/*.h")
FILE(GLOB DATA_SOURCES "Data/*.cpp")
SET (DATA ${DATA_HEADERS} ${DATA_SOURCES})
SOURCE_GROUP(Data FILES ${DATA})
# Data End

# Gui Begin
FILE(GLOB GUI_HEADERS "Gui/*.h")
FILE(GLOB GUI_SOURCES "Gui/*.cpp")
SET (GUI ${GUI_HEADERS} ${GUI_SOURCES})
SOURCE_GROUP(Gui FILES ${GUI})

QT5_WRAP_CPP(GUI_HEADERS_MOC ${GUI_HEADERS})
SOURCE_GROUP(MOC FILES ${GUI_HEADERS_MOC})

LIST(APPEND GUI ${GUI_HEADERS_MOC})
# Gui End

# Source Begin
FILE(GLOB HEADERS "*.h")
FILE(GLOB SOURCES "*.cpp")

QT5_WRAP_CPP(HEADERS_MOC ${HEADERS})
SOURCE_GROUP(MOC FILES ${HEADERS_MOC})
# Source End

SET(FILES
    ${DATA}
    ${GUI}
    ${HEADERS}
    ${SOURCES}
    ${HEADERS_MOC}
)

IF(WIN32)
    ADD_EXECUTABLE(FileDispatcher WIN32 ${FILES})
ELSE(WIN32)
    ADD_EXECUTABLE(FileDispatcher ${FILES})
ENDIF(WIN32)
TARGET_LINK_LIBRARIES(FileDispatcher
                      ${Qt5Core_QTMAIN_LIBRARIES}
                      ${Qt5Widgets_LIBRARIES}
                      ${Qt5Gui_LIBRARIES}
                      ${Qt5Sql_LIBRARIES})
